package com.zmzncs.lmtc.module.order.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zmzncs.lmtc.common.pojo.PageInfo;
import com.zmzncs.lmtc.common.pojo.Rest;
import com.zmzncs.lmtc.common.util.JsonUtil;
import com.zmzncs.lmtc.common.util.RestUtil;
import com.zmzncs.lmtc.module.order.pojo.order_Info.*;
import com.zmzncs.lmtc.module.order.service.OrderInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Random;


/**
 * <p>
 * 客户-信息 前端控制器
 * </p>
 *
 * @author 任建波
 * @since 2020-09-01
 */
@Api(tags = "订单")
@RestController
@RequestMapping("/order/orderInfo")
@Slf4j
public class OrderInfoController {

    @Autowired
    private OrderInfoService orderInfoService;

    @ApiOperation(value = "订单条件分页查询")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "header", name = "token", value = "请求头token", required = true),
    })
    @GetMapping(value = "getOrderByManage")
    public Rest<PageInfo<OrderInfoTableVO>> getOrderByManage(OrderInfoManageForm form) {
        IPage<OrderInfoDTO> page = orderInfoService.getOrderByManage(form);

        PageInfo<OrderInfoTableVO> pageInfo = JsonUtil.pageTransform(page, OrderInfoTableVO.class);

        return RestUtil.success(pageInfo);
    }

    @ApiOperation(value = "数据大屏进出场车辆信息")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "header", name = "token", value = "请求头token", required = true),
    })
    @GetMapping(value = "getCarInList")
    public Rest<List<CarInModel>> getCarInList() {
        List<CarInModel> list = orderInfoService.getCarInList();
        return RestUtil.success(list);
    }

    @ApiOperation(value = "已使用车位数")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "header", name = "token", value = "请求头token", required = true),
    })
    @GetMapping(value = "usedParking")
    public Rest<Integer> usedParking() {
        int min = -30;
        int max = Math.abs(min);
        int randNumber = new Random().nextInt(max - min + 1) + min;
        int count = 23213 + randNumber;

        return RestUtil.success(count);
    }

}

